package com.atguigu.rabbitmq.consumer.listeners;


import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Author ChenYongSheng
 * Date 2025/10/31 19:12
 */
@Component
public class ConsumerListener {

    @RabbitListener(queues = "test-queue")// 监听方法，test-queue有方法的时候会自动调用
    public void getQueueInfo1(Message message){
        byte[] messageBody = message.getBody();
        String messageString = new String(messageBody);
        System.out.println("message1 = " + messageString);

    }

    @RabbitListener(queues = "test-queue")// 监听方法，test-queue有方法的时候会自动调用
    public void getQueueInfo2(Message message){
        byte[] messageBody = message.getBody();
        String messageString = new String(messageBody);
        System.out.println("message2 = " + messageString);

    }
}
